cr	equ	0dh
lf	equ	0ah
	org	100h
Start:	jmp	Begin
Msg1	db	'Vvedite chislo i najmite Enter:', cr, lf, '$'
Msg2	db	'Vvedite trehznachnie chisla, razdelennie probelom i najmite Enter:', cr, lf, '$'
MsgErr	db	'Oshibka!!!', cr, lf, '$'
MinNumb	dw	0
MStr1	db	81
LStr1   db	0
StrNumb1 times	81	db	0
MStr2	db	81
LStr2   db	0
StrNumb2 times	81	db	0
Begin:
	mov	ah,09h
	mov	dx,Msg1
	int	21h
	mov	ah,0ah
	mov	dx,MStr1
	int	21h
	mov	ah,02h
	mov	dl,0ah
	int	21h
	cmp	[LStr1],byte 0
	jz	.Exit

 	xor	ax,ax
	xor	bx,bx
	xor	cx,cx
	xor	dx,dx
	xor	si,si
	mov	cl,[LStr1]
	mov	bl,10
.L1:	mov	dl,[StrNumb1+si]
	inc	si
	cmp	dl,39h
	ja	.Err
	cmp	dl,30h
	jb	.Err
	cmp	dl,30h
	jne	.M1
	cmp	si,1
	je	.Err
.M1:	mul	bl
	sub	dl,30h
	add	al,dl
	loop .L1
	mov	[MinNumb],ax

	mov	ah,09h
	mov	dx,Msg2
	int	21h
	mov	ah,0ah
	mov	dx,MStr2
	int	21h
	mov	ah,02h
	mov	dl,0ah
	int	21h
	cmp	[LStr2],byte 0
	jz	.Exit

  	xor	ax,ax
	xor	bx,bx
	xor	cx,cx
	xor	dx,dx
	xor	si,si
	xor	di,di
	mov	cl,[LStr2]
	mov	bl,10
.L2:	mov	dl,[StrNumb2+si]
	inc	si
	cmp	dl,39h
	ja	.Err
	cmp	dl,30h
	jb	.M2
	cmp	dl,30h
	jne	.M4
	cmp	di,0
	je	.Err
.M4:	mul	bl
	sub	dl,30h
	add	al,dl
	inc	di
	jmp	.M3
.M2:	cmp	dl,20h
	jne	.Err
	cmp	di,3
	jne	.Err
	cmp	ax,[MinNumb]
	ja	.M5	
	mov	[MinNumb],ax
.M5:	xor	ax,ax
	xor	di,di
.M3:	loop .L2
	cmp	ax,[MinNumb]
	ja	.M6	
	mov	[MinNumb],ax

.M6:	mov	ax,[MinNumb]
	mov	bx,10
	xor	cx,cx
.M7:	xor	dx,dx
	div	bx
	push	dx
	inc	cx
	cmp	ax,0
	jne	.M7
.L3:    pop	ax
	add	al,30h
	mov	ah,02h
	mov	dl,al
	int	21h
	loop	.L3

	mov	ah,02h
	mov	dl,cr
	int	21h
	mov	dl,lf
	int	21h

	mov	bx,[MinNumb]
	mov	cx,16
.L4:	mov	dx,0
	rcl	bx,1
	adc	dl,30h
	mov	ah,02h
	int	21h
	loop	.L4
	jmp	.Exit

.Err:	mov	ah,09h
	mov	dx,MsgErr
	int	21h
.Exit:	mov	ax,4c00h
	int	21h
